
import { EventTouch, Label, Node, Sprite, Toggle, _decorator, director, game } from "cc";
import { BaseUI } from "../../framework/base/BaseUI";
import { AudioMgr } from "../../framework/manager/AudioMgr";
import { CacheUtils } from "../../framework/utils/CacheUtils";
import { AudioId, EventName, UIID } from "../config/Config";
import { PlayerMgr } from "../manager/PlayerMgr";
import { EventMgr } from "../../framework/manager/EventMgr";
import { UIMgr } from "../../framework/manager/UIMgr";
const { ccclass, property } = _decorator;

@ccclass('UICloudData')
export class UICloudData extends BaseUI {

    /**底部节点 */
    @property(Node)
    downNode: Node = null;



    callback: Function = null

    /**动画节点 */
    @property(Label)
    tipText: Label = null;

    //是否正在游戏
    isGaming: boolean = false;
    // //退出回调
    // callback_backHome: Function = null;
    // //重置回调
    // callback_resetStart: Function = null;

    private isSetting: boolean = false
    private isChange: boolean = false
    private serverData: any = {}
    public init(param1?: any, param2?: any, param3?: any, param4?: any, param5?: any): void {
        this.callback = param2;
        this.tipText.string = `发现云存档,已解锁${param1.level}关，是否使用云存档继续游戏?`
        this.serverData = param1
    }

    start() {
        this.initModule();
        this.initView();
    }

    initModule() {

    }

    closeBtn() {
        // EventMgr.getInstance().emit(EventName.closeSet)
        this.closeUI();
    }

    clickGet() {
        // PlayerMgr.getInstance().getUserData().data = this.serverData;
        PlayerMgr.getInstance().getUserData().saveServerData(this.serverData);
        // UIMgr.getInstance().closeById(UIID.UICloudData)
        // if(window['wx']){
        //     window['wx'].restartMiniProgram({})
        // }else{
        //     // director.runScene(director.getScene())
        // }
        this.callback&&this.callback(true)
        this.closeUI();
    }
    onCloseView() {
        this.callback&&this.callback()
        this.closeUI();
    }

    initView() {
      
    }

  

    onCloseUI(uid: any, msg: string) {

    }

}
